function getLength(str: string | number): number {
    if ((<string>str).length) {
        return (<string>str).length
    } else {
        return str.toString().length
    }
}
console.log(getLength('张三'))